package com.scsj.supermarket.presenter;

import android.util.Log;

import com.orhanobut.logger.Logger;
import com.scsj.supermarket.base.AppCommodityEvaluationBase;
import com.scsj.supermarket.base.QueryMineOrderBase;
import com.scsj.supermarket.bean.AppCommodityEvaluationBean;
import com.scsj.supermarket.bean.MineOrderBean;
import com.scsj.supermarket.bean.SelectAppRankBean;
import com.scsj.supermarket.model.AppCommodityEvaluationModel;
import com.scsj.supermarket.model.QueryMineOrderModel;

import dkmvp.mvp.BasePresenter;
import dkmvp.net.ResponseCallback;
import okhttp3.RequestBody;

/**
 * App显示商品评论和店铺评论
 */
public class AppCommodityEvaluationPresenter extends BasePresenter implements AppCommodityEvaluationBase.IPresenter {
    private AppCommodityEvaluationBase.IView mView;
    private AppCommodityEvaluationBase.IModel mModel;

    public AppCommodityEvaluationPresenter(AppCommodityEvaluationBase.IView mView) {
        this.mView = mView;
        mModel = new AppCommodityEvaluationModel();
    }

    @Override
    public void deliverData(RequestBody requestBody) {
        addSubscription(mModel.getData(requestBody, new ResponseCallback<AppCommodityEvaluationBean>() {
            @Override
            public void onSuccess(AppCommodityEvaluationBean result) {

                if (result.getStatusCode()== 200) {
                    mView.showSuccessMsg("获取成功",result);
                    Logger.e("获取成功" + result.toString());
                } else {
                    mView.showErrorMsg(result.getMsg());
                    Logger.e("获取店铺评论的失败" + result.toString());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Logger.e("获取店铺评论Error==>"+ msg );
            }
        }));
    }

    @Override
    public void deliverSelectData(RequestBody requestBody) {
        addSubscription(mModel.getSelectData(requestBody, new ResponseCallback<SelectAppRankBean>() {
            @Override
            public void onSuccess(SelectAppRankBean result) {

                if (result.getStatusCode()== 200) {
                    mView.showSelectSuccessMsg("获取成功",result);
                    Logger.e("获取成功" + result.toString());
                } else {
                    mView.showErrorMsg(result.getMsg());
                    Logger.e("未成功" + result.toString());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Log.e("失败", msg + "");
            }
        }));
    }
}
